package cn.agiledata.bank.audit.logic;

import java.util.Iterator;
import java.util.Set;

import cn.agiledata.bank.hibernateBean.AuditGroup;
import cn.agiledata.bank.hibernateBean.Operator;
import cn.agiledata.bank.hibernateBean.UserInfo;

public class AuditGroupWrapper {
    private AuditGroup auditGroup;

    public AuditGroupWrapper(AuditGroup auditGroup) {
        this.auditGroup = auditGroup;
    }

    public AuditGroup getAuditGroup() {
        return this.auditGroup;
    }

    public boolean containsOperator(Operator operator) {
        if (operator == null) {
            return false;
        }
        Set operators = this.getAuditGroup().getOperators();
        for (Iterator it = operators.iterator(); it.hasNext();) {
            Operator o = (Operator) it.next();
            if (o.getId().equals(operator.getId()))
                return true;
        }
        return false;
    }

    public boolean containsUser(UserInfo user) {
        Set users = getAuditGroup().getUsers();
        for (Iterator it = users.iterator(); it.hasNext();) {
            UserInfo u = (UserInfo) it.next();
            if (u.getId().equals(user.getId())) {
                return true;
            }
        }
        return false;
    }
}
